Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@hixme-ui/theme-props

Package Overview
Dependencies
Maintainers
2
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hixme-ui/theme-props

hixme-ui theme props getters

  • 1.20.7
  • npm
  • Socket score

Version published
Weekly downloads
77
increased by220.83%
Maintainers
2
Weekly downloads
 
Created
Source

Theme Props

Utility for parsing theme properties by CSS attribute name and props passed in by the component

npm i --save @hixme-ui/theme-props

Theme props getters for the HUI theme

These are named exports from the theme props package. The default function uses the the base theme.colors object as shown above.

This container example defaults to none for the background, but if white is sent a boolean prop, it will add the blue background color from the theme.

import styled from 'styled-components'
import { getBackgroundColor } from '@hixme-ui/theme-props'

const Container = styled.div`
  background: ${(props) => getBackgroundColor(props, 'none')
`
  • getBackgroundColor() theme.backgroundColors
  • getBorderColor() theme.borderColors
  • getButtonBorderRadius() theme.buttonBorderRadius
  • getButtonFontSize() theme.fontSizes
  • getButtonGradientColor() theme.buttonGradientColors
  • getButtonHeight() theme.buttonHeights
  • getButtonMinWidth() theme.buttonMinWidths
  • getButtonTextColor() theme.buttonTextColors
  • getFontFamily() theme.fontFamily
  • getFontSize() theme.fontSizes
  • getFontWeight() theme.fontWeights
  • getOutlineButtonColor() theme.outlineButtonColors
  • getShadow() theme.shadows
  • getTextColor() theme.textColors

getThemePropsComposer(propsName, defaultValue)

Top level function by which all other theme prop utilities are built. The propsName should map to a object of values on the theme.

import React from 'react'
import styled from 'styled-components'
import themeProps from '@hixme-ui/theme-props'

const theme = {
  colors: {
    white: '#ffffff',
    black: '#000000',
    red: '#ff0000',
    green: '#00ff00',
    blue: '#0000ff',
  }
}
 
const ColorText = styled.span`
  color: ${props => getTextColor(props, '#000000')};
`

const App = () => (
  <ThemeProvider theme={theme}>
    <ColorText green>Hello!</ColorText>
    <ColorText blue>Hope you have a great day!</ColorText>
  </ThemeProvider>
)

Keywords

FAQs

Package last updated on 15 Nov 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc